/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.dusin.wufang.graph.shape;

import com.mxgraph.canvas.mxGraphics2DCanvas;
import com.mxgraph.shape.mxBasicShape;
import com.mxgraph.view.mxCellState;
import java.awt.Rectangle;

/**
 *
 * @author Admin
 */
public class BianYaQi3 extends mxBasicShape{
        public void paintShape(mxGraphics2DCanvas canvas, mxCellState state)
	{
		Rectangle rect = state.getRectangle();
		int x = rect.x;
		int y = rect.y;
		int w = rect.width;
		int h = rect.height;
		
		
                int r=w/3;
                int r2=h/3;
              
               
		// Paints the foreground
		if (configureGraphics(canvas, state, false))
		{
			//canvas.getGraphics().drawOval(x, y, 2*r-r/5, 2*r2-r/5);
                        //canvas.getGraphics().drawLine(x+(2*r-r/5)/2, y+(2*r2-r/5)/2, x+(2*r-r/5)/2,y+(2*r2-r/5)/4);
                       // int dx =  (int)((2*r-r/5)/4*Math.cos(Math.toRadians(30)));
                        //int dy = (int)((2*r-r/5)/4*Math.sin(Math.toRadians(30)));
                       // canvas.getGraphics().drawLine(x+(2*r-r/5)/2, y+(2*r2-r/5)/2, x+(2*r-r/5)/2-dx, y+(2*r2-r/5)/2+dy);
                       // canvas.getGraphics().drawLine(x+(2*r-r/5)/2, y+(2*r2-r/5)/2,x+(2*r-r/5)/2+dx,y+(2*r2-r/5)/2+dy);
                        
                      // canvas.getGraphics().drawOval(x+r, y, 2*r, 2*r2);
                        
                      //  canvas.getGraphics().drawOval(x+2*r/3, y+r2, 2*r, 2*r2);	
                     
                    canvas.getGraphics().drawOval(x, y, 2*r-r*3/8, 2*r2-r2*3/8);
                    canvas.getGraphics().drawLine(x+(2*r-r*3/8)/2, y+(2*r-r*3/8)/2, x+(2*r-r*3/8)/2,y+(2*r2-r2*3/8)/4);
                    int dx =  (int)((2*r-r*3/8)/4*Math.cos(Math.toRadians(30)));
                    int dy = (int)((2*r-r*3/8)/4*Math.sin(Math.toRadians(30))); 
                    canvas.getGraphics().drawLine(x+(2*r-r*3/8)/2, y+(2*r2-r2*3/8)/2, x+(2*r-r*3/8)/2-dx, y+(2*r2-r2*3/8)/2+dy);
                    canvas.getGraphics().drawLine(x+(2*r-r*3/8)/2, y+(2*r2-r2*3/8)/2,x+(2*r-r*3/8)/2+dx,y+(2*r2-r2*3/8)/2+dy);
                   
                    canvas.getGraphics().drawOval(x+3*r/2-5, y-1/2*r-3, 2*r-r*3/8, 2*r2-r2*3/8);
                    int dx2 =  (int)((2*r-r*3/8)/2*Math.cos(Math.toRadians(30)));
                    int dy2 = (int)((2*r-r*3/8)/2*Math.sin(Math.toRadians(30))); 
                    canvas.getGraphics().drawLine(x+3*r/2-5+(2*r-r*3/8)/2, y-1/2*r-3+(2*r-r*3/8)*3/4, x+3*r/2-5+(2*r-r*3/8)/2,y-1/2*r-3+(2*r-r*3/8)*3/4-(2*r2-r2*3/8)/2);
                    canvas.getGraphics().drawLine(x+3*r/2-5+(2*r-r*3/8)/2 ,y-1/2*r-3+(2*r-r*3/8)*3/4 ,x+3*r/2-5+(2*r-r*3/8)/2+dx2 ,y-1/2*r-3+(2*r-r*3/8)*3/4-dy2);
                    canvas.getGraphics().drawLine(x+3*r/2-5+(2*r-r*3/8)/2 ,y-1/2*r-3+(2*r-r*3/8)/4  ,x+3*r/2-5+(2*r-r*3/8)/2+dx2,y-1/2*r-3+(2*r-r*3/8)/4 +dy2);
                   
                    canvas.getGraphics().drawOval(x+2*r/3, y+r2+3/8*r2, 2*r-3/8*r2-3, 2*r2-3/8*r2-3);
                    canvas.getGraphics().drawLine(x+2*r/3+(2*r-3/8*r)/2,y+r2+3/8*r2+(2*r-3/8*r)/2,x+2*r/3+(2*r-3/8*r)/2 ,y+r2+3/8*r2+(2*r2-3/8*r2)/4);
                    canvas.getGraphics().drawLine(x+2*r/3+(2*r-3/8*r)/2, y+r2+3/8*r2+(2*r-3/8*r)/2, x+2*r/3+(2*r-3/8*r)/2-dx,y+r2+3/8*r2+(2*r-3/8*r)/2+dy);
                    canvas.getGraphics().drawLine(x+2*r/3+(2*r-3/8*r)/2, y+r2+3/8*r2+(2*r-3/8*r)/2,x+2*r/3+(2*r-3/8*r)/2+dx,y+r2+3/8*r2+(2*r-3/8*r)/2+dy);
		}                
	}
   
}
